package org.carry.god.framework.web.core.handler;

import org.carry.god.framework.common.exception.ServiceException;
import org.carry.god.framework.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author wanglei
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    /**
     * 处理业务异常 ServiceException
     */
    @ExceptionHandler(value = ServiceException.class)
    public CommonResult<?> serviceExceptionHandler(ServiceException ex) {
        return CommonResult.error(ex.getCode(), ex.getMessage());
    }
}
